
package com.ctw.mapmycity.model;
import com.ctw.mapmycity.R;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;


public class CustomMarker {

	private MarkerOptions markerOptionCustom;
	private PostModel postModel;
	private LatLng point;
	
	int count = 0;

	public String getSnippet() {
		StringBuilder snippet = new StringBuilder();
		if (postModel != null){
			snippet.append(postModel.getAddress()).append(";")
			.append(postModel.getCity()).append(";")
			.append(postModel.getType()).append(";")
			.append(postModel.getState()).append(";")
			.append(postModel.getDate()).append(";")
			.append(postModel.getTime()).append(";")
			.append(postModel.getDescription()).append(";")
			.append(postModel.getTypeKey()).append(";")
			.append(postModel.isBoRegistered()).append(";")
			.append(postModel.getId());
		}
		return snippet.toString();
	}

	public CustomMarker (PostModel postModel, LatLng point) {
		this.postModel = postModel;
		this.point = point;
	}

	public MarkerOptions getMarkerOptionCustom() {
		BitmapDescriptor icon = null;
		
		switch (postModel.getTypeKey()) {
			
			case 0: // Furto
				icon = BitmapDescriptorFactory.fromResource(R.drawable.azure_furto48);
				break;
			case 1: // Roubo de veiculo
				icon = BitmapDescriptorFactory.fromResource(R.drawable.chartreuse_rouboveiculo48);
				break;
				
			case 2: // Assalto a mao armada
				icon = BitmapDescriptorFactory.fromResource(R.drawable.azure_maoarmada48);
				break;
	
			case 3: // Sequestro
				icon = BitmapDescriptorFactory.fromResource(R.drawable.pink_sequestro48);
				break;
	
			case 4: // Homicidio
				icon = BitmapDescriptorFactory.fromResource(R.drawable.pink_homicio48);
				break;
		}
		
		markerOptionCustom = new MarkerOptions().position(point).title(postModel.getType()).snippet(getSnippet()).icon(icon);
		return markerOptionCustom;
		
	}

	public void setMarkerOptionCustom(MarkerOptions markerOptionCustom) {
		this.markerOptionCustom = markerOptionCustom;
	}


	public PostModel getPostModel() {
		return postModel;
	}


	public void setPostModel(PostModel postModel) {
		this.postModel = postModel;
	}
}
